/**
 * Created with IntelliJ IDEA.
 * Description:异常
 * User: dings
 * Date: 2024-04-28
 * Time: 12:43
 */
public class Test {
    public static int func(int x,int y) throws ArithmeticException{
        if(y == 0) {
            throw new ArithmeticException("y == 0");
        }
        return x/y;
    }

    public static void main(String[] args) {
        try {
            int ret = func(10,0);
            System.out.println(ret);
        }catch (ArithmeticException e) {
            e.printStackTrace();
            System.out.println("捕捉到了算术异常");
        }
     }
}
